<template>
    <div class="countyInfo">        
        <!--专题标题 -->
        <div class="special_title" v-if="specialList.length > 0">
            {{specialList[0].specialTitle}}
            <br> <br>
        </div>
        <!--本县专题内容 -->
        <yd-list theme="5" v-if="specialList.length > 0">
            <div v-for="(item,index) in specialList" :key="index">
                <div class="special_info" v-html="item.specialContent"></div>
            </div>
        </yd-list>
        <div v-else class="special_noData"> {{noInfoMsg}} </div>

        <!--购物车  -->
        <!-- <div class="shopping" @click="shoppingCart">
            <yd-icon name="shopcart-outline" size='0.5rem'></yd-icon>
            <yd-badge class="badge" type="danger" v-if="shoppingNum>0">{{shoppingNum}}</yd-badge>
        </div> -->
    </div>
</template>
<script>

export default {
    name: 'countyInfo',
    data() {
        return {
            imgUrl: this.CONSTANT.imgBaseUrl,
            specialList: [],
            countyId: '',
            shoppingNum: 0,
            noInfoMsg: '',
        }
    },
    created: function() {
        this.countyId = this.$route.query.countyId;
        this.init();
    },
    methods: {
        init() {
            this.$dialog.loading.open('请稍后');
            // 从扶贫专题管理表取得专题封面图、专题正文内容
            this.$axios.get(this.CONSTANT.wapiBaseUrl + 'supportPoor/specialInfo?countyId=' + this.countyId)
                .then((response) => {
                    this.$dialog.loading.close();
                    if (response.status == 200) {
                        let countySupportPoor = response.data.object;
                        this.specialList = response.data.object.specialList;
                        // 标题设置
                        window.document.title = countySupportPoor.countyName + "概况";
                    }                    

                    // // 购物车件数的取得
                    // this.nums();

                   if (this.specialList.length == 0) {
                        this.noInfoMsg = '本县扶贫专题未设定,本县概况暂无';
                    }
                }).catch((error) => {
                    this.$dialog.loading.close();
                    this.$dialog.toast({
                        mes: '本县概况信息的取得失败，请联系客服',
                        icon: 'error',
                        timeout: 1500
                    });
                });
        },
        nums() {
            this.$axios.get(this.CONSTANT.wapiBaseUrl + 'member/statistics')
                .then((response) => {
                    this.$dialog.loading.close();
                    if (response.status == 200) {
                        this.shoppingNum = response.data.object.cartGoodsNum;
                    }
                }).catch(error => {
                    this.$dialog.loading.close();
                    this.$dialog.toast({
                        mes: '购物车信息的取得失败，请联系客服',
                        icon: 'error',
                        timeout: 1500
                    });
                });
        },
        shoppingCart() {
            this.$router.push('/shoppingCart');
        },
    }
}
</script>
<style  scoped>
.countyInfo {
    width: 100%;
    margin: 0 auto;
    color: #727272;
    height: 100%;
    background-color:#FFF;
}

.special_title {
    font-size:0.4rem;
    padding:0.2rem;
}
.special_info {
    font-size: 14px;
    text-align: justify;
    box-sizing: border-box;
    padding: 0.2rem;
    margin-bottom: 0.2rem;
}
.special_noData {
   font-size:0.4rem;
   padding-top:1rem;
   padding-left: 0.2rem;
}

/*购物车*/
.shopping {
    position: fixed;
    right: 5%;
    bottom: 1rem;
    width: 1rem;
    z-index: 99;
    text-align: center;
    line-height: 1rem;
    color: #fff;
    font-weight: 400;
    height: 1rem;
    border-radius: 50%;
    background: #F4A9A3;
}
.badge {
    position: absolute;
    right: 0;
    top: -0.1rem;
}
</style>